package com.redstar.HappyRefresh.pojo;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

@Data
@EqualsAndHashCode(callSuper = false)
public class Type implements Serializable { // 分类

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @TableLogic
    private Boolean isDeleted; // 逻辑删除，0为未删除，1为删除，默认为0

    @TableField(fill = FieldFill.INSERT)
    private Date gmtCreated;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date gmtUpdated;

    @NotBlank(message = "分类名称不可为空")
    private String name;

    private String description;

    private String icon; // 图标

    private Boolean open; // 是否公开

    private String labelNames; // 分类标签

    @TableField(exist = false)
    private Boolean used; // 当前用户是否订阅

    public List<String> buildLabel(){
        String[] labelNum = labelNames.split(",");
        return Arrays.asList(labelNum);
    }
}

